<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Feedback extends Admin_Controller {
    private $webmaster_config = 'config';
    private $model_config     = 'feedback';
    public function __construct(){
        parent::__construct();
        $this->load->library('form_validation');
        $this->load->library('image_lib');
        $this->set_webmaster_config(); //添加后台配置文件
    }
    private function set_webmaster_config(){
        $model=$this->uri->segment(1);
        $this->webmaster_config=$this->config->item('webmaster');
        $this->model_config=$this->config->item($model); //article
    }

    public function info_list(){
        $query_string     = query_string('page');
        $webmaster_config = $this->webmaster_config;
        $model_config 	  = $this->model_config;
        //-------翻页 start------//
        $where = "1=1";
        $page_count=$model_config['feedback_page_count'];
        $row_count=$this->data->get_row_count('ca_feedback', $where);
        $total_pages=ceil($row_count/$page_count);
        $page=(int)$_GET['page'];
        $page<1 && $page=1;
        $page>$total_pages && $page=1;
        $start_row=($page-1)*$page_count;
        $query_string=base_url('/feedback/info_list/').'?'.query_string('page').'&page=';
        $turn_page = turn_page($page, $total_pages, $query_string, $row_count, 'Previous', 'Next',3,'style="margin:0px; text-align:right;"');
        $list = $this->data->get_limit('ca_feedback',$where,"*","fid desc", $start_row, $page_count);
        //-------翻页 end------//
        $data=array(
            'list' => $list
        );
        $this->load->view(THEME_PATH.'/feedback.php',$data);
    }

    public function info_mod(){
        $query_string     = query_string('page');
        $fid			  = (int)$_GET['fid'];
        $item			  = $this->data->get_one('ca_feedback',"fid='$fid'");
        $page_name	 	  = 'feedback';
        $webmaster_config = $this->webmaster_config;
        $model_config 	  = $this->model_config;
        $data=array(
            'group_id'				=> $group_id,
            'page_name'				=> $page_name,
            'model_config'  		=> $model_config,
            'webmaster_config'		=> $webmaster_config,
            'item'					=> $item,
            'aid'					=> $aid,
            'query_string'			=> $query_string
        );
        $this->load->view(THEME_PATH.'/article.php',$data);
    }

    public function list_del_action(){
        $query_string     = $_GET['query_string'];
        $info_id    	  = (int)$this->input->post('id',true);
        $this->data->delete('ca_feedback',"fid='$info_id'");
        e_json($query_string,1);
    }

    public function group_del(){
        $group_id	= $this->input->post('group_id',true);
        $ary		= explode('|', $group_id);
        foreach((array)$ary as $k=>$v){
            $this->data->delete('ca_feedback',"fid='$v'");
        }
        e_json($group_id,1);
    }
}
?>